<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>东单办公系统-部门新增</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="media/layui/css/layui.css" media="all">
    <script type="text/javascript" src="media/js/jquery.min.js"></script>
    <script type="text/javascript">
        $(function() {
            var json = getData();
            var obj = JSON.parse(decodeURI(json));
            //var obj = JSON.parse(json);
            console.log(obj);
            showData(obj);
        })

        function getData() {
            var url = window.location.search;
            index = url.indexOf("?");
            if (index > -1) {
                var str = url.substr(index + 1);
                if (str.indexOf('=')) {
                    return str.split('=')[1];
                }
            }
            return null;
        }
        function showData(obj) {
            $("#f1").val(obj.name);
            $("#f2").val(obj.createtime);
            $("#f3").val(obj.week);
            $("#f5").val(obj.id);
        }
    </script>
</head>
<body>
<div class="layui-container" style="margin-top: 5px">
    <form class="layui-form">
        <div class="layui-form-item">
            <input type="hidden" name="id" id="f5"> <label
                class="layui-form-label">学科名称</label>
            <div class="layui-input-block">
                <input type="text" name="name" lay-verify="name" autocomplete="off"
                       placeholder="请输入学科名称" class="layui-input" id="f1">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">成立日期</label>
            <div class="layui-input-block">
                <input type="text" name="createtime" autocomplete="off"
                       class="layui-input" id="f2" readonly="readonly">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">学科周期</label>
            <div class="layui-input-block">
                <input type="number" name="week" lay-verify="name"
                       autocomplete="off" placeholder="请输入学科周期" class="layui-input"
                       id="f3">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">学科类型</label>
            <div class="layui-input-block">
                <select name="type" lay-verify="required" id="f4">
                    <option value="1">普通版</option>
                    <option value="2">GP</option>
                    <option value="3">混合学科</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <button class="layui-btn" style="margin-left: 100px" type="submit" onclick="clickit()">修改</button>
        </div>
    </form>
</div>


<script src="media/layui/layui.js"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    function clickit() {
        $.ajax({
            type:"post",
            data:$('form').serialize(),
            url:"course/courseupdate.do",
            success:function (res) {
                console.log(res)
                if(res.code==1){
                    //console.log("修改成功")
                    alert("修改成功")
                    window.location.href="courselist.html"
                }else{
                    alert(1)
                }
            },
            error:function () {
                console.log("error")
            }
        })
        return false;
    }
</script>
<script>
    layui.use([ 'form', 'laydate' ], function() {
        var form = layui.form, layer = layui.layer,laydate=layui.laydate;
    });
</script>
</body>
</html>